
<template>
  <view class="page-container">
    <scroll-view scroll-y="true" class="page-body py-32">
      <view class="box-shadows py-32 px-32  mt-24" v-for="n in listData" :key="n.id" @click="toDetail(n)">
        <view class="flex items-center justify-between font-bold font-28">
          <view class="">{{testPaperName}}</view>
          <view class="">{{n.score}}分</view>
        </view>
        <view class="mt-24 text-99">考试时间：{{n.createTime}}</view>
      </view>
      <up-empty marginTop="100" text="暂无考试记录'" v-if="listData.length === 0&&loading"></up-empty>
    </scroll-view>
  </view>
</template>
<script setup>
import { ref} from 'vue'
import {onLoad,onShow} from "@dcloudio/uni-app"
import utils from '@/utils/utils.js'
import  {subject} from '@/api'
import useUserStore from '@/store/user.js'
const useStore = useUserStore()
const listData = ref([])
const testPaperName = ref('')
const loading = ref(false)
const toDetail = (item) => {
  uni.navigateTo({
    url: `/pages/my/examRecords/historyExam?id=${item.id}`
  })
}
onLoad(async (options) => {
  console.log('options:', options)
  if (options.id) {
    const res = await subject.getSubjectRecordList({uid: useStore.uid, categoryId: options.id})
    if (res.code === 0) {
      listData.value = res.data || []
      loading.value = true
      console.log('listData.value:', listData.value)
    }
  }
  if(options.name){
    testPaperName.value = options.name
  }
})
</script>
<style scoped lang="scss">
</style>